package Arrays;
/*
java.util.Math 类是数学相关的工具类，里面提供了大量的静态方法，完成与数学运算相关的操作

public static double abs(double num):获取绝对值。
public static double ceil(double num):向上取整
public static double floor(double num)：向下取整
public static double round(double num)：四舍五入

Math.PI代表近似的圆周率常量


 */
public class Demo02Math {
    public static void main(String[] args) {

        //获取绝对值
        System.out.println(Math.abs(3.11));
        System.out.println(Math.abs(5));
        System.out.println(Math.abs(-2.66));
        System.out.println("============");

        //向上取整
        System.out.println(Math.ceil(3.9));
        System.out.println(Math.ceil(3.1));
        System.out.println(Math.ceil(3.0));
        System.out.println("==================");

        //向下取整
        System.out.println(Math.floor(30.9));
        System.out.println(Math.floor(30.1));
        System.out.println(Math.floor(31.0));
        System.out.println("==================");

        //四舍五入
        System.out.println(Math.round(20.6));
        System.out.println(Math.round(20.8));
        System.out.println(Math.round(19.2));
        System.out.println(Math.round(18.1));
    }


}
